package ModelLayer;

public class SystemInfo
{
    //instance variables
    private static SystemInfo instance = null;
    private String action;
    private String err;
    
    /**
     * Constructor for objects of class SystemInfo
     */
    private SystemInfo()
    {
        action = "";
        err = "";
    }
    
    /**
     * Singleton static inplementation  
     */
    public static SystemInfo getInstance()
    {
        if(instance == null)
            instance = new SystemInfo();
        return instance;
    }
    
     /**
     * Accessor, Mutator and List methods
     */
    
    public void setAction(int _action)
    {
        if(_action == 1)
        {
            action = "Add/Create";
        }
        else
        {
            if(_action == 2)
            {
                action = "Delete";
            }
            else
            {
                if(_action == 3)
                {
                    action = "Update";
                }
            }   
        }
    }
    
    public void setError(int _err)
    {
        if(_err == 0)
        {
            err = "";
        }
        else
        {
            if(_err == 1)
            {
                err = "The object does not exist";
            }
            else
            {
                if(_err == 2)
                {
                    err = "The object in already present";
                }
            }
        }
    }
    
    public boolean printMessage()
    {
        boolean problem = false;
        if(err == "")
        {
            System.out.println(action + " operation was completed successfully!");
        }
        else
        {
            System.out.println(action + " operation was NOT completed successfully!\nError: " + err);
            problem = true;
        }
        return problem;
    }
}
